@import "../../themes/ionic.globals.wp";

// Windows Toolbar
// --------------------------------------------------

/// @prop - Order of the toolbar elements
$toolbar-order-wp: (
  back-button: 0,
  menu-toggle-start: 1,
  buttons-left: 2,
  content: 3,
  buttons-start: 4,
  buttons-end: 5,
  buttons-right: 6,
  menu-toggle-end: 7,
) !default;

// deprecated
$toolbar-wp-title-padding:               null !default;

/// @prop - Padding top of the toolbar title
$toolbar-wp-title-padding-top:           0 !default;

/// @prop - Padding end of the toolbar title
$toolbar-wp-title-padding-end:           6px !default;

/// @prop - Padding bottom of the toolbar title
$toolbar-wp-title-padding-bottom:        $toolbar-wp-title-padding-top !default;

/// @prop - Padding start of the toolbar title
$toolbar-wp-title-padding-start:         $toolbar-wp-title-padding-end !default;

/// @prop - Font size of the toolbar title
$toolbar-wp-title-font-size:             1.5rem !default;

/// @prop - Font weight of the toolbar title
$toolbar-wp-title-font-weight:           bold !default;

/// @prop - Text transform of the toolbar title
$toolbar-wp-title-text-transform:        uppercase !default;

/// @prop - Text color of the toolbar title
$toolbar-wp-title-text-color:            color-contrast($colors-wp, $toolbar-wp-background, wp) !default;

/// @prop - Font size of the toolbar button
$toolbar-wp-button-font-size:            1.4rem !default;

/// @prop - Text color of the toolbar button
$toolbar-wp-button-color:                color-contrast($colors-wp, $toolbar-wp-background, wp) !default;

/// @prop - Border radius of the toolbar button
$toolbar-wp-button-border-radius:        2px !default;

/// @prop - Font weight of the strong toolbar button
$toolbar-wp-button-strong-font-weight:   bold !default;

/// @prop - Height of the navigation bar
$navbar-wp-height:                       $toolbar-wp-height !default;

$toolbar-button-wp-strong-font-weight:   bold !default;


.toolbar-wp {
  @include padding($toolbar-wp-padding);

  min-height: $toolbar-wp-height;
}


// Windows Toolbar Background
// --------------------------------------------------

.toolbar-background-wp {
  border-color: $toolbar-wp-border-color;
  background: $toolbar-wp-background;
}


// Windows Toolbar Content
// --------------------------------------------------

.toolbar-content-wp {
  flex: 1;
  order: map-get($toolbar-order-wp, content);

  min-width: 0;
  max-width: 100%;
}

.toolbar-title-wp {
  font-size: $toolbar-wp-title-font-size;
  font-weight: $toolbar-wp-title-font-weight;
  text-transform: $toolbar-wp-title-text-transform;
  color: $toolbar-wp-title-text-color;

  @include deprecated-variable(padding, $toolbar-wp-title-padding) {
    @include padding($toolbar-wp-title-padding-top, $toolbar-wp-title-padding-end, $toolbar-wp-title-padding-bottom, $toolbar-wp-title-padding-start);
  }
}

@mixin wp-toolbar-theme($color-name, $color-base, $color-contrast) {

  .toolbar-wp-#{$color-name} .toolbar-background-wp {
    background: $color-base;
  }

  .toolbar-wp-#{$color-name} .bar-button-clear-wp,
  .toolbar-wp-#{$color-name} .bar-button-default-wp,
  .toolbar-wp-#{$color-name} .bar-button-outline-wp,
  .toolbar-wp-#{$color-name} .toolbar-title-wp {
    color: $color-contrast;
  }

  .toolbar-wp-#{$color-name} .bar-button-outline-wp {
    border-color: $color-contrast;
  }

  .toolbar-wp-#{$color-name} {
    @each $color-name, $color-base, $color-contrast in get-colors($colors-wp) {
      @include wp-bar-button-default($color-name, $color-base, $color-contrast);
      @include wp-bar-button-outline($color-name, $color-base, $color-contrast);
      @include wp-bar-button-solid($color-name, $color-base, $color-contrast);
    }
  }
}


// Windows Toolbar Button Placement
// --------------------------------------------------

.bar-buttons-wp {
  order: map-get($toolbar-order-wp, buttons-start);

  transform: translateZ(0);
}

.bar-buttons-wp[left] {
  order: map-get($toolbar-order-wp, buttons-left);
}

.bar-buttons-wp[left] .bar-button:first-child {
  @include margin-horizontal(0, null);
}

.bar-buttons-wp[end] {
  @include text-align(end);

  order: map-get($toolbar-order-wp, buttons-end);
}

.bar-buttons-wp[right] {
  @include text-align(right);

  order: map-get($toolbar-order-wp, buttons-right);
}


// Windows Toolbar Button Default
// --------------------------------------------------

.bar-button-wp {
  @include margin(0, .2rem);
  @include padding(0, 5px);
  @include border-radius($toolbar-wp-button-border-radius);

  height: 32px;

  border: 0;
  font-size: $toolbar-wp-button-font-size;
  font-weight: 500;
  text-transform: uppercase;
}

.bar-button-solid-wp,
.bar-button-outline-wp {
  // restrict the ripple to button size
  overflow: hidden;
}

@mixin wp-bar-button-default($color-name, $color-base, $color-contrast) {

  .bar-button-#{$color-name}-wp,
  .bar-button-clear-wp-#{$color-name},
  .bar-button-wp-#{$color-name} {
    color: $color-base;
    background-color: transparent;

    &:hover:not(.disable-hover) {
      color: $color-base;
    }
  }

}


// Windows Toolbar Button Outline
// --------------------------------------------------

.bar-button-outline-wp {
  border-width: 1px;
  border-style: solid;
  border-color: $toolbar-wp-button-color;
  color: $toolbar-wp-button-color;
  background-color: transparent;

  &:hover:not(.disable-hover) {
    opacity: .4;
  }

  &.activated {
    color: color-contrast($colors-wp, $toolbar-wp-button-color, wp);
    background-color: $toolbar-wp-button-color;
  }
}

@mixin wp-bar-button-outline($color-name, $color-base, $color-contrast) {

  .bar-button-outline-wp-#{$color-name} {
    $fg-color: color-shade($color-base);
    border-color: $fg-color;
    color: $fg-color;
    background-color: transparent;

    &.activated {
      color: $color-contrast;
      background-color: $fg-color;
    }
  }

}


// Windows Toolbar Button Solid
// --------------------------------------------------

.bar-button-solid-wp {
  color: color-contrast($colors-wp, $toolbar-wp-button-color, wp);
  background-color: $toolbar-wp-button-color;

  &:hover:not(.disable-hover) {
    color: color-contrast($colors-wp, $toolbar-wp-button-color, wp);
  }

  &.activated {
    color: color-contrast($colors-wp, $toolbar-wp-button-color, wp);
    background-color: color-shade($toolbar-wp-button-color);
  }
}

@mixin wp-bar-button-solid($color-name, $color-base, $color-contrast) {

  .bar-button-solid-wp-#{$color-name} {
    color: $color-contrast;
    background-color: $color-base;

    &.activated {
      color: $color-contrast;
      background-color: color-shade($color-base);
    }
  }

}


// Windows Toolbar Button Icon
// --------------------------------------------------

.bar-button-wp.bar-button-icon-start ion-icon {
  @include padding-horizontal(null, .3em);

  font-size: 1.4em;
  line-height: .67;

  pointer-events: none;
}

.bar-button-wp.bar-button-icon-end ion-icon {
  @include padding-horizontal(.4em, null);

  font-size: 1.4em;
  line-height: .67;

  pointer-events: none;
}

.bar-button-wp[icon-only] {
  @include padding(0);

  ion-icon {
    @include padding(0, .1em);

    min-width: 28px;

    font-size: 1.8em;
    line-height: .67;

    pointer-events: none;
  }
}


// Windows Toolbar Back Button
// --------------------------------------------------

.back-button-wp {
  @include margin(0, 6px);

  min-width: 44px;

  box-shadow: none;
}

.back-button-icon-wp {
  @include text-align(start);
  @include margin(0);
  @include padding(0, 6px);

  font-size: 2.4rem;
  font-weight: normal;
}


// Windows Toolbar Menu Toggle
// --------------------------------------------------

.bar-button-menutoggle-wp {
  @include margin(0, 6px);
  @include padding(0, 2px);

  order: map-get($toolbar-order-wp, menu-toggle-start);

  min-width: 44px;

  ion-icon {
    @include padding(0, 6px);

    font-size: 2.4rem;
  }
}

.bar-button-menutoggle-wp[end],
.bar-button-menutoggle-wp[right] {
  @include margin(0, 2px);

  order: map-get($toolbar-order-wp, menu-toggle-end);

  min-width: 28px;
}


// Windows Toolbar Color Generation
// --------------------------------------------------

@include wp-bar-button-default(default, $toolbar-wp-button-color, color-contrast($colors-wp, $toolbar-wp-button-color, wp));
@include wp-bar-button-default(clear, $toolbar-wp-button-color, color-contrast($colors-wp, $toolbar-wp-button-color, wp));

@each $color-name, $color-base, $color-contrast in get-colors($colors-wp) {
  @include wp-toolbar-theme($color-name, $color-base, $color-contrast);
  @include wp-bar-button-default($color-name, $color-base, $color-contrast);
  @include wp-bar-button-outline($color-name, $color-base, $color-contrast);
  @include wp-bar-button-solid($color-name, $color-base, $color-contrast);
}


// WP strong Button
// --------------------------------------------------

.bar-button-strong-wp {
  font-weight: $toolbar-wp-button-strong-font-weight;
}
